#include <stdio.h>
int main() {
    int n;
    scanf("%d", &n);
    int count = 1;
    int row = 0, col = 0;
    int arr[50][50] = { 0 };
    int i = 0;
    while (count <= n * n)
    {
        for (int i = 0; i < 2; i++)
        {
            if (row < n && col < n)
            {
                arr[row][col] = count++;
            }
            col++;
        }
        col--;
        while (col)
        {
            row++;
            col--;
            if (row < n && col < n)
            {
                arr[row][col] = count++;
            }
        }
        row++;
        while (row)
        {
            if (row < n && col < n)
            {
                arr[row][col] = count++;
            }
            row--;
            col++;
        }
    }
    for (row = 0; row < n; row++)
    {
        for (int col = 0; col < n; col++)
        {
            printf("%d ", arr[row][col]);
        }
        printf("\n");
    }
    return 0;
}